package com.jianjun.ktui.ui.screen

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.paint
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.savedstate.SavedState
import androidx.savedstate.savedState
import com.jianjun.ktui.Greeting
import jianjun_gradle.composeapp.generated.resources.Res
import jianjun_gradle.composeapp.generated.resources.login_background
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.ui.tooling.preview.Preview

/**
 *
 * @author source
 * {@code @date} 2025/3/27 09:30
 */
@Composable
fun IndexScreen(
    showSnackbar: (String) -> Unit,
    uiState: SavedState,
) {
    Box(
        modifier = Modifier
            .paint(painterResource(Res.drawable.login_background), contentScale = ContentScale.FillBounds),
        contentAlignment = Alignment.Center
    ) {
        val greeting = remember { Greeting().greet() }
        Text(
            greeting,
            color = Color.White,
            modifier = Modifier.align(Alignment.BottomCenter).padding(20.dp),
            maxLines = 1,
            textAlign = TextAlign.Center
        )
    }
}

@Preview(widthDp = 700, heightDp = 500)
@Composable
fun IndexScreenPreview() {
    IndexScreen(
        showSnackbar = {},
        uiState = savedState()
    )
}